<?php 
/**
 * ... ...
 * ... ...
 *
 */ 



// 载入父 类 
//<<[UnmodifiableBlock.Start]::Include Parent Class::>>//
JCAT_Package::ImportClass('JCAT_UIGtkCtrlTree',JCAT::PACKAGE_UICTRLGTK) ;
//<<[UnmodifiableBlock.End]::Include Parent Class::>>//

// 载入所需的 数据校验器 类 
//<<[UnmodifiableBlock.Start]::Include Data Verifier Class::>>//
JCAT_Package::ImportClass('JCAT_UICtrlLengthVerifier',JCAT::PACKAGE_MVCDV) ;
//<<[UnmodifiableBlock.End]::Include Data Verifier Class::>>//

/**
 * JCAT_UIGtkCtrlTree 类型UI控件 TreeTables 
 * 
 * @access	public
 * @author	由 JeCat PHP Toolbox 产生 
 */
class TreeTables 
	//<<[UnmodifiableBlock.Start]::Extends::>>//
	extends JCAT_UIGtkCtrlTree 
	//<<[UnmodifiableBlock.End]::Extends::>>//
{
	/**
	 * TreeTables类 的 构造函数 
	 * 
	 * @access	public
	 * @return	void
	 */
	public function TreeTables($sWidgetId='TreeLeftTables',$sUIName,$arrTables)
	{
		// 初始化 父类 
		$this->JCAT_UIGtkCtrlTree($sWidgetId,$sUIName,$sWidgetId) ; 

		// 创建并载入 数据校验器 
		//<<[UnmodifiableBlock.Start]::Data Verifier::>>//
		// 最小值:1; 不允许为空
		$this->AddVerifier(JCAT_Flyweight::GetGlobalInstance('JCAT_UICtrlLengthVerifier',1,-1,false)) ;
		//<<[UnmodifiableBlock.End]::Data Verifier::>>//


		// 在此添加 初始化 代码 
		// TODO ... ...
		$this->aTablesMode = new GtkTreeStore(Gtk::TYPE_STRING) ;
		foreach ($arrTables as $sTableName)
		{
			$this->aTablesMode->append(null,array($sTableName)) ;
		}

	}
	
	/**
	 * 创建一个  GtkTreeModel 模型  
	 * 
	 * @access	public
	 * @return	void
	 */
	public function CreateModel()
	{
		//<<[UnmodifiableBlock.Start]::Create Model::>>//
		$aModel = new GtkTreeStore(
			Gtk::TYPE_STRING
			) ;
		//<<[UnmodifiableBlock.End]::Create Model::>>//
		
		// 在此添加代码  
		// TODO ... ...
		
		return $aModel ;
	}
	
	/**
	 * 初始化  GtkTreeView 的列  
	 * 
	 * @access	public
	 * @return	void
	 */
	public function InitializeColumns()
	{
		// 取得视图 
		$wndTreeView = $this->GetMainWidget() ;
		JCAT_ASSERT::ASSERT_INSTANCE($wndTreeView,'GtkTreeView',
					JCAT_Language::SentenceEx('UI控件“%”的主窗体尚未创建，在正常情况下  InitializeColumns()不应该被直接调用，UI控件的主窗体在创建之时，会自动调用此方法。','JCAT',null,$this->GetName())) ;

		// 设置 视图上的 各列 
		//<<[UnmodifiableBlock.Start]::Setting Columns::>>//
		// 视图列：数据表
		$aRenderForColumn0 = new GtkCellRendererCombo() ;
		$aRenderForColumn0->set_property('editable',true) ;
		$aRenderForColumn0->connect('edited',array($this,'OnTextEdit'),self::CLM_TABLE) ;
		$wndColumn0 = new GtkTreeViewColumn(JCAT_Language::Sentence('数据表'),$aRenderForColumn0,'text',self::CLM_TABLE) ;
		$wndTreeView->append_column($wndColumn0) ;
		//<<[UnmodifiableBlock.End]::Setting Columns::>>//
		

		// 在此添加 代码 
		// TODO ... ...
		$aRender = $this->GetCellRender(self::CLM_TABLE) ;
		$aRender->set_property('model',$this->aTablesMode) ;
		$aRender->set_property('text_column',0) ;

		// 添加活动行
		//$aModel = $this->GetGtkModel() ;
		//$aItem = $aModel->append(null,array('')) ;
		//$this->EditCell($aItem,self::CLM_TABLE);
	}

	
	/**
	 * 
	 *
	 * @access	public
	 * @return	int
	 */
	public function GetDataLength()
	{
		$nRet = 0 ;
		
		$aModel = $this->GetGtkModel() ; 
		if( is_object($aModel) )
		{
			$aIterator = new JCAT_GtkTreeItemIterator($aModel) ;
			$aIterator->First() ;
			while( !$aIterator->IsDone() )
			{
				$aItem = $aIterator->Current() ;
				if( $this->GetCellData($aItem,self::CLM_TABLE)!=='' )
				{
					$nRet ++ ;	
				}		
				
				$aIterator->Next() ;
			}
		}
		
		return $nRet ;
	}
	
	
	/**
	 * what's this
	 * 
	 * @access	public
	 * @param	$aRenderer		GtkCellRendererText		what's this
	 * @param	$sPath			string					what's this
	 * @param	$sNewText		string					what's this
	 * @param	$nColumn		int						what's this
	 * @return	void
	 */
	public function OnTextEdit( GtkCellRendererText $aRenderer , $sPath, $sNewText, $nColumn )
	{
		//$aModel = $this->GetGtkModel() ;
		$aItem = $this->GetItem($sPath) ;
		JCAT_ASSERT::ASSERT_INSTANCE($aItem) ;

		// 删除
		if($sNewText=='')
		{
			$this->RemoveItem($aItem) ;
		}
		else 
		{
			parent::OnTextEdit( $aRenderer , $sPath, $sNewText, $nColumn ) ;
		}
		
		// 末尾 加入新行
		$aLastItem = $this->GetLastItem(null,false) ;
		if( $aLastItem===null or $this->GetCellData($aLastItem,self::CLM_TABLE)!=='' )
		{
			$this->AppendItem(array('')) ;
		}
	}
	
	// 为 视图的列 定义常量 
	//<<[UnmodifiableBlock.Start]::Define Column Consts::>>//
	const CLM_TABLE = 0 ;
	//<<[UnmodifiableBlock.End]::Define Column Consts::>>//


}






?><?
/**
 * [注意!!]
 *	以下内容由 JCAT PHP Toolbox 自动维护，手动更改的内容会被 JCAT PHP Toolbox 抹除，
 *	同时还可能破坏格式，导致 JCAT PHP Toolbox 无法正常读取。
 */
/*<<[UnmodifiableBlock.Start]::Coder Dialog Data::>>&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&//
<<{{DocumentClass:UICtrlGtkTreeDoc}}>>
eCVEQW1TJUNGJThFJUUyNiUxOCVCRlclRUFLcCVBQyVENEklMDglQjAlM0IlMEQlQUIlOTUrJTA5bCVEQ0klODIlOEQlMUQlODYlQjklOEMyJUUwJTFEQkwyJTg1TCUyMSslMUUlQTElQzclM0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